import { Message } from 'view-design'

export const showLoading = (opt = { content: '执行操作中,请稍后..', delay: 0 }) => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      Message.loading({
        content: opt.content,
        duration: 0
      })
    }, opt.delay)
  })
}

export const hideLoading = (delay) => {
  if (delay) {
    setTimeout(() => {
      Message.destroy()
    }, delay * 1000)
  } else Message.destroy()
}

export default {
  showLoading,
  hideLoading
}
